{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 汽车数据爬虫\n",
    "\n",
    "- 汽车的列表首页：https://car.autohome.com.cn/#pvareaid=2042193\n",
    "- 汽车品牌树状图：https://car.autohome.com.cn/AsLeftMenu/As_LeftListNew.ashx?typeId=1%20&brandId=0%20&fctId=0%20&seriesId=0\n",
    "- 汽车的详细信息：https://car.autohome.com.cn/price/series-3895-0-3-0-0-0-0-1.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import time\n",
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "import util\n",
    "import random\n",
    "import re \n",
    "import json\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# 获取所有汽车的品牌信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "url = 'https://car.autohome.com.cn/AsLeftMenu/As_LeftListNew.ashx?typeId=1%20&brandId=0%20&fctId=0%20&seriesId=0'\n",
    "\n",
    "headers = {\n",
    "    'accept': '*/*',\n",
    "    'accept-encoding': 'gzip, deflate, br',\n",
    "    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',\n",
    "    'cookie': 'sessid=08D91723-37C5-453D-7ABC-8A9BF37F999E; aQQ_ajkguid=68BF0D90-336E-78C7-CA8D-47A5392F562B; lps=http%3A%2F%2Fsuzhou.anjuke.com%2Fmarket%7Chttps%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3D7XM-380vWFgagNC5ukas6apKUcXO6ck-cprY021q6qEUIQV0oMmNHwwedazMVSmA%26ck%3D8728.1.8.255.233.269.237.743%26shh%3Dwww.baidu.com%26sht%3D02003390_43_hao_pg%26wd%3D%26eqid%3D8da5d22900033baa000000035e4df41b; twe=2; 58tj_uuid=7a0db2eb-1e28-4f2e-a165-ed315faf38bf; als=0; ajk_member_captcha=f1de250c288c0c20646940c4404457f6; _ga=GA1.2.1359141188.1582167400; ctid=37; _gid=GA1.2.748970654.1586016697; wmda_uuid=c75e0177ece7c3ffe9393596e9cffcfd; wmda_new_uuid=1; wmda_visited_projects=%3B6289197098934; wmda_session_id_6289197098934=1586090511651-40fe9ec3-ab6c-0ca3; init_refer=http%253A%252F%252Flocalhost%253A8888%252Fnotebooks%252F%2525E8%2525B4%2525B5%2525E9%252598%2525B3%2525E6%252588%2525BF%2525E4%2525BB%2525B7%2525E6%252595%2525B0%2525E6%25258D%2525AE%2525E7%252588%2525AC%2525E8%252599%2525AB.ipynb; new_uv=14; new_session=0; browse_comm_ids=282172%7C974667; propertys=svxlz5-q8bgbr_wx7z94-q8bg4d_; xzfzqtoken=KveeN6LAJygcDMglgXLnw%2Bk9ONWn6Gu8p%2BRx8Hioc2YlTqyUkEeLhC2sFABI8Rvvin35brBb%2F%2FeSODvMgkQULA%3D%3D',\n",
    "    'referer': 'https://car.autohome.com.cn/',\n",
    "    'sec-fetch-dest': 'empty',\n",
    "    'sec-fetch-mode': 'cors',\n",
    "    'sec-fetch-site': 'same-origin',\n",
    "    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'\n",
    "}\n",
    "\n",
    "response = requests.get(url, headers=headers)\n",
    "response.encoding = 'gbk'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "soup = BeautifulSoup(response.text[18:-3], 'lxml')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "scrolled": false,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "brands = soup.find_all('a')\n",
    "\n",
    "brand_urls = {}\n",
    "for brand in brands:\n",
    "    brand_name = brand.text\n",
    "    brand_href = 'https://car.autohome.com.cn' + brand['href']\n",
    "    brand_urls[brand_name.split('(')[0]] = brand_href"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AC Schnitzer\tALPINA\tARCFOX极狐\tAUXUN傲旋\t阿尔法·罗密欧\t阿斯顿·马丁\t爱驰\t奥迪\tBEIJING汽车\t巴博斯\t宝骏\t宝马\t宝骐汽车\t宝沃\t保时捷\t北京\t北汽昌河\t北汽道达\t北汽幻速\t北汽威旺\t北汽新能源\t北汽制造\t奔驰\t奔腾\t本田\t比德文汽车\t比克汽车\t比速汽车\t比亚迪\t标致\t别克\t宾利\t铂驰\t布加迪\t长安\t长安凯程\t长安跨越\t长安欧尚\t长城\t车驰汽车\t成功汽车\tDS\t大乘汽车\t大发\t大运\t大众\t道奇\t电咖\t东风\t东风·瑞泰特\t东风风度\t东风风光\t东风风神\t东风风行\t东风富康\t东风小康\t东南\t法拉利\t飞碟汽车\t菲亚特\t丰田\t枫叶汽车\t福迪\t福汽启腾\t福特\t福田\tGMC\t高合汽车\t观致\t光冈\t广汽埃安\t广汽传祺\t广汽吉奥\t广汽集团\t广汽蔚来\t国机智骏\t国金汽车\t哈飞\t哈弗\t海格\t海马\t汉龙汽车\t汉腾汽车\t悍马\t恒天\t红旗\t红星汽车\t华凯\t华普\t华骐\t华颂\t华泰\t华泰新能源\t黄海\tIcona\tIMSA英飒\tJeep\t吉利汽车\t几何汽车\t江淮\t江铃\t江铃集团新能源\t捷豹\t捷达\t捷尼赛思\t捷途\t金杯\t金冠汽车\t金龙\t金旅\t九龙\t君马汽车\t钧天\tKarma\tKTM\t卡尔森\t卡升\t卡威\t开瑞\t开沃汽车\t凯迪拉克\t凯翼\t科尼赛克\t克莱斯勒\tLEVC\tLITE\tLOCAL MOTORS\tLorinser\tLUMMA\t兰博基尼\t劳斯莱斯\t雷丁\t雷克萨斯\t雷诺\t理念\t理想汽车\t力帆汽车\t莲花汽车\t猎豹汽车\t林肯\t凌宝汽车\t铃木\t零跑汽车\t领克\t领途汽车\t陆地方舟\t陆风\t路虎\t路特斯\t罗夫哈特\tMINI\t马自达\t玛莎拉蒂\t迈巴赫\t迈凯伦\t迈迈\t迈莎锐\t名爵\t摩根\t哪吒汽车\t纳智捷\t讴歌\t欧宝\t欧拉\t欧朗\tPolestar极星\t帕加尼\t奇瑞\t骐铃汽车\t启辰\t起亚\t前途\t乔治·巴顿\t庆铃汽车\t全球鹰\tR汽车\t日产\t荣威\t容大智造\t如虎\t瑞驰新能源\t瑞麒\tSERES赛力斯\tSHELBY\tsmart\tSONGSAN MOTORS\tSRM鑫源\tSWM斯威汽车\t萨博\t赛麟\t三菱\t陕汽通家\t上汽大通MAXUS\t上喆\t神州\t世爵\t双环\t双龙\t思皓\t思铭\t斯巴鲁\t斯达泰克\t斯柯达\t速达\t泰卡特\t特斯拉\t腾势\t天际汽车\t天美汽车\tWEY\t瓦滋\t威麟\t威马汽车\t威兹曼\t潍柴汽车\t潍柴英致\t蔚来\t沃尔沃\t五菱汽车\t五十铃\t西雅特\t现代\t小鹏汽车\t晓奥汽车\t新宝骏\t新凯\t新特汽车\t星途\t雪佛兰\t雪铁龙\t野马汽车\t野马新能源\t一汽\t一汽凌河\t依维柯\t银隆新能源\t英菲尼迪\t永源\t宇通客车\t驭胜\t御捷\t裕路\t远程汽车\t云度\t云雀汽车\t之诺\t知豆\t中华\t中兴\t众泰\n"
     ]
    }
   ],
   "source": [
    "print('\\t'.join(list(brand_urls.keys())))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "def fetch_brand_cars_info(brand, url):\n",
    "    headers = {\n",
    "    'accept': '*/*',\n",
    "    'accept-encoding': 'gzip, deflate, br',\n",
    "    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',\n",
    "    'cookie': 'sessid=08D91723-37C5-453D-7ABC-8A9BF37F999E; aQQ_ajkguid=68BF0D90-336E-78C7-CA8D-47A5392F562B; lps=http%3A%2F%2Fsuzhou.anjuke.com%2Fmarket%7Chttps%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3D7XM-380vWFgagNC5ukas6apKUcXO6ck-cprY021q6qEUIQV0oMmNHwwedazMVSmA%26ck%3D8728.1.8.255.233.269.237.743%26shh%3Dwww.baidu.com%26sht%3D02003390_43_hao_pg%26wd%3D%26eqid%3D8da5d22900033baa000000035e4df41b; twe=2; 58tj_uuid=7a0db2eb-1e28-4f2e-a165-ed315faf38bf; als=0; ajk_member_captcha=f1de250c288c0c20646940c4404457f6; _ga=GA1.2.1359141188.1582167400; ctid=37; _gid=GA1.2.748970654.1586016697; wmda_uuid=c75e0177ece7c3ffe9393596e9cffcfd; wmda_new_uuid=1; wmda_visited_projects=%3B6289197098934; wmda_session_id_6289197098934=1586090511651-40fe9ec3-ab6c-0ca3; init_refer=http%253A%252F%252Flocalhost%253A8888%252Fnotebooks%252F%2525E8%2525B4%2525B5%2525E9%252598%2525B3%2525E6%252588%2525BF%2525E4%2525BB%2525B7%2525E6%252595%2525B0%2525E6%25258D%2525AE%2525E7%252588%2525AC%2525E8%252599%2525AB.ipynb; new_uv=14; new_session=0; browse_comm_ids=282172%7C974667; propertys=svxlz5-q8bgbr_wx7z94-q8bg4d_; xzfzqtoken=KveeN6LAJygcDMglgXLnw%2Bk9ONWn6Gu8p%2BRx8Hioc2YlTqyUkEeLhC2sFABI8Rvvin35brBb%2F%2FeSODvMgkQULA%3D%3D',\n",
    "    'referer': url,\n",
    "    'sec-fetch-dest': 'empty',\n",
    "    'sec-fetch-mode': 'cors',\n",
    "    'sec-fetch-site': 'same-origin',\n",
    "    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'\n",
    "    }\n",
    "\n",
    "    response = requests.get(url, headers=headers)\n",
    "    response.encoding = 'gbk'\n",
    "    soup = BeautifulSoup(response.text, 'lxml')\n",
    "    cars = soup.select('div.list-cont')\n",
    "    \n",
    "    brand_cars = []\n",
    "    for car in cars:\n",
    "        car_info = {'品牌': brand}\n",
    "        name = car.select('a.font-bold')[0].text\n",
    "        score = car.select('span.score-number')\n",
    "        if len(score) == 0:\n",
    "            score = '暂无'\n",
    "        else:\n",
    "            score = score[0].text\n",
    "        \n",
    "        car_info['车系'] = name\n",
    "        car_info['评分'] = score\n",
    "        \n",
    "        ul = car.select('ul.lever-ul')[0]\n",
    "        for li in ul.select('li'):\n",
    "            data = li.text.replace('\\xa0', '').replace('&nbsp;', '').replace(' ', '').strip().split('：')\n",
    "            if '颜色' in data[0]: continue\n",
    "            if len(data) < 2: continue\n",
    "            car_info[data[0]] = data[1]\n",
    "        \n",
    "        price = car.select('span.font-arial')[0].text\n",
    "        price = price.split('-')\n",
    "        if len(price) == 1:\n",
    "            car_info['最低指导价'] = price[0]\n",
    "            car_info['最高指导价'] = price[0]\n",
    "        else:\n",
    "            car_info['最低指导价'] = price[0] + '万'\n",
    "            car_info['最高指导价'] = price[1]\n",
    "            \n",
    "        car_info['链接'] = url\n",
    "        brand_cars.append(car_info)\n",
    "    \n",
    "    return brand_cars\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {
    "scrolled": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--> 爬取 AC Schnitzer 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-117.html 。。。\n",
      "--> 爬取 ALPINA 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-276.html 。。。\n",
      "--> 爬取 ARCFOX极狐 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-272.html 。。。\n",
      "--> 爬取 AUXUN傲旋 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-378.html 。。。\n",
      "--> 爬取 阿尔法·罗密欧 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-34.html 。。。\n",
      "--> 爬取 阿斯顿·马丁 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-35.html 。。。\n",
      "--> 爬取 爱驰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-327.html 。。。\n",
      "--> 爬取 奥迪 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-33.html 。。。\n",
      "--> 爬取 BEIJING汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-173.html 。。。\n",
      "--> 爬取 巴博斯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-140.html 。。。\n",
      "--> 爬取 宝骏 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-120.html 。。。\n",
      "--> 爬取 宝马 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-15.html 。。。\n",
      "--> 爬取 宝骐汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-351.html 。。。\n",
      "--> 爬取 宝沃 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-231.html 。。。\n",
      "--> 爬取 保时捷 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-40.html 。。。\n",
      "--> 爬取 北京 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-27.html 。。。\n",
      "--> 爬取 北汽昌河 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-79.html 。。。\n",
      "--> 爬取 北汽道达 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-301.html 。。。\n",
      "--> 爬取 北汽幻速 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-203.html 。。。\n",
      "--> 爬取 北汽威旺 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-143.html 。。。\n",
      "--> 爬取 北汽新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-208.html 。。。\n",
      "--> 爬取 北汽制造 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-154.html 。。。\n",
      "--> 爬取 奔驰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-36.html 。。。\n",
      "--> 爬取 奔腾 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-95.html 。。。\n",
      "--> 爬取 本田 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-14.html 。。。\n",
      "--> 爬取 比德文汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-387.html 。。。\n",
      "--> 爬取 比克汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-440.html 。。。\n",
      "--> 爬取 比速汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-271.html 。。。\n",
      "--> 爬取 比亚迪 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-75.html 。。。\n",
      "--> 爬取 标致 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-13.html 。。。\n",
      "--> 爬取 别克 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-38.html 。。。\n",
      "--> 爬取 宾利 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-39.html 。。。\n",
      "--> 爬取 铂驰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-392.html 。。。\n",
      "--> 爬取 布加迪 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-37.html 。。。\n",
      "--> 爬取 长安 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-76.html 。。。\n",
      "--> 爬取 长安凯程 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-294.html 。。。\n",
      "--> 爬取 长安跨越 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-299.html 。。。\n",
      "--> 爬取 长安欧尚 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-163.html 。。。\n",
      "--> 爬取 长城 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-77.html 。。。\n",
      "--> 爬取 车驰汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-366.html 。。。\n",
      "--> 爬取 成功汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-196.html 。。。\n",
      "--> 爬取 DS 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-169.html 。。。\n",
      "--> 爬取 大乘汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-341.html 。。。\n",
      "--> 爬取 大发 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-92.html 。。。\n",
      "--> 爬取 大运 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-405.html 。。。\n",
      "--> 爬取 大众 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-1.html 。。。\n",
      "--> 爬取 道奇 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-41.html 。。。\n",
      "--> 爬取 电咖 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-280.html 。。。\n",
      "--> 爬取 东风 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-32.html 。。。\n",
      "--> 爬取 东风·瑞泰特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-326.html 。。。\n",
      "--> 爬取 东风风度 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-187.html 。。。\n",
      "--> 爬取 东风风光 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-259.html 。。。\n",
      "--> 爬取 东风风神 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-113.html 。。。\n",
      "--> 爬取 东风风行 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-165.html 。。。\n",
      "--> 爬取 东风富康 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-406.html 。。。\n",
      "--> 爬取 东风小康 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-142.html 。。。\n",
      "--> 爬取 东南 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-81.html 。。。\n",
      "--> 爬取 法拉利 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-42.html 。。。\n",
      "--> 爬取 飞碟汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-434.html 。。。\n",
      "--> 爬取 菲亚特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-11.html 。。。\n",
      "--> 爬取 丰田 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-3.html 。。。\n",
      "--> 爬取 枫叶汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-416.html 。。。\n",
      "--> 爬取 福迪 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-141.html 。。。\n",
      "--> 爬取 福汽启腾 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-197.html 。。。\n",
      "--> 爬取 福特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-8.html 。。。\n",
      "--> 爬取 福田 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-96.html 。。。\n",
      "--> 爬取 GMC 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-112.html 。。。\n",
      "--> 爬取 高合汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-383.html 。。。\n",
      "--> 爬取 观致 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-152.html 。。。\n",
      "--> 爬取 光冈 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-116.html 。。。\n",
      "--> 爬取 广汽埃安 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-313.html 。。。\n",
      "--> 爬取 广汽传祺 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-82.html 。。。\n",
      "--> 爬取 广汽吉奥 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-108.html 。。。\n",
      "--> 爬取 广汽集团 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-329.html 。。。\n",
      "--> 爬取 广汽蔚来 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-376.html 。。。\n",
      "--> 爬取 国机智骏 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-369.html 。。。\n",
      "--> 爬取 国金汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-304.html 。。。\n",
      "--> 爬取 哈飞 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-24.html 。。。\n",
      "--> 爬取 哈弗 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-181.html 。。。\n",
      "--> 爬取 海格 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-150.html 。。。\n",
      "--> 爬取 海马 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-86.html 。。。\n",
      "--> 爬取 汉龙汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-386.html 。。。\n",
      "--> 爬取 汉腾汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-267.html 。。。\n",
      "--> 爬取 悍马 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-43.html 。。。\n",
      "--> 爬取 恒天 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-164.html 。。。\n",
      "--> 爬取 红旗 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-91.html 。。。\n",
      "--> 爬取 红星汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-336.html 。。。\n",
      "--> 爬取 华凯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-245.html 。。。\n",
      "--> 爬取 华普 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-85.html 。。。\n",
      "--> 爬取 华骐 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-184.html 。。。\n",
      "--> 爬取 华颂 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-220.html 。。。\n",
      "--> 爬取 华泰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-87.html 。。。\n",
      "--> 爬取 华泰新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-260.html 。。。\n",
      "--> 爬取 黄海 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-97.html 。。。\n",
      "--> 爬取 Icona 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-188.html 。。。\n",
      "--> 爬取 IMSA英飒 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-429.html 。。。\n",
      "--> 爬取 Jeep 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-46.html 。。。\n",
      "--> 爬取 吉利汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-25.html 。。。\n",
      "--> 爬取 几何汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-373.html 。。。\n",
      "--> 爬取 江淮 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-84.html 。。。\n",
      "--> 爬取 江铃 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-119.html 。。。\n",
      "--> 爬取 江铃集团新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-270.html 。。。\n",
      "--> 爬取 捷豹 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-44.html 。。。\n",
      "--> 爬取 捷达 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-358.html 。。。\n",
      "--> 爬取 捷尼赛思 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-371.html 。。。\n",
      "--> 爬取 捷途 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-319.html 。。。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--> 爬取 金杯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-83.html 。。。\n",
      "--> 爬取 金冠汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-419.html 。。。\n",
      "--> 爬取 金龙 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-145.html 。。。\n",
      "--> 爬取 金旅 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-175.html 。。。\n",
      "--> 爬取 九龙 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-151.html 。。。\n",
      "--> 爬取 君马汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-297.html 。。。\n",
      "--> 爬取 钧天 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-356.html 。。。\n",
      "--> 爬取 Karma 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-353.html 。。。\n",
      "--> 爬取 KTM 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-109.html 。。。\n",
      "--> 爬取 卡尔森 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-156.html 。。。\n",
      "--> 爬取 卡升 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-224.html 。。。\n",
      "--> 爬取 卡威 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-199.html 。。。\n",
      "--> 爬取 开瑞 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-101.html 。。。\n",
      "--> 爬取 开沃汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-213.html 。。。\n",
      "--> 爬取 凯迪拉克 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-47.html 。。。\n",
      "--> 爬取 凯翼 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-214.html 。。。\n",
      "--> 爬取 科尼赛克 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-100.html 。。。\n",
      "--> 爬取 克莱斯勒 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-9.html 。。。\n",
      "--> 爬取 LEVC 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-320.html 。。。\n",
      "--> 爬取 LITE 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-335.html 。。。\n",
      "--> 爬取 LOCAL MOTORS 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-241.html 。。。\n",
      "--> 爬取 Lorinser 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-118.html 。。。\n",
      "--> 爬取 LUMMA 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-441.html 。。。\n",
      "--> 爬取 兰博基尼 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-48.html 。。。\n",
      "--> 爬取 劳斯莱斯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-54.html 。。。\n",
      "--> 爬取 雷丁 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-215.html 。。。\n",
      "--> 爬取 雷克萨斯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-52.html 。。。\n",
      "--> 爬取 雷诺 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-10.html 。。。\n",
      "--> 爬取 理念 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-124.html 。。。\n",
      "--> 爬取 理想汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-345.html 。。。\n",
      "--> 爬取 力帆汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-80.html 。。。\n",
      "--> 爬取 莲花汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-89.html 。。。\n",
      "--> 爬取 猎豹汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-78.html 。。。\n",
      "--> 爬取 林肯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-51.html 。。。\n",
      "--> 爬取 凌宝汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-420.html 。。。\n",
      "--> 爬取 铃木 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-53.html 。。。\n",
      "--> 爬取 零跑汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-318.html 。。。\n",
      "--> 爬取 领克 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-279.html 。。。\n",
      "--> 爬取 领途汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-343.html 。。。\n",
      "--> 爬取 陆地方舟 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-204.html 。。。\n",
      "--> 爬取 陆风 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-88.html 。。。\n",
      "--> 爬取 路虎 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-49.html 。。。\n",
      "--> 爬取 路特斯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-50.html 。。。\n",
      "--> 爬取 罗夫哈特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-346.html 。。。\n",
      "--> 爬取 MINI 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-56.html 。。。\n",
      "--> 爬取 马自达 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-58.html 。。。\n",
      "--> 爬取 玛莎拉蒂 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-57.html 。。。\n",
      "--> 爬取 迈巴赫 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-55.html 。。。\n",
      "--> 爬取 迈凯伦 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-129.html 。。。\n",
      "--> 爬取 迈迈 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-381.html 。。。\n",
      "--> 爬取 迈莎锐 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-374.html 。。。\n",
      "--> 爬取 名爵 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-20.html 。。。\n",
      "--> 爬取 摩根 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-168.html 。。。\n",
      "--> 爬取 哪吒汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-309.html 。。。\n",
      "--> 爬取 纳智捷 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-130.html 。。。\n",
      "--> 爬取 讴歌 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-60.html 。。。\n",
      "--> 爬取 欧宝 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-59.html 。。。\n",
      "--> 爬取 欧拉 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-331.html 。。。\n",
      "--> 爬取 欧朗 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-146.html 。。。\n",
      "--> 爬取 Polestar极星 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-308.html 。。。\n",
      "--> 爬取 帕加尼 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-61.html 。。。\n",
      "--> 爬取 奇瑞 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-26.html 。。。\n",
      "--> 爬取 骐铃汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-210.html 。。。\n",
      "--> 爬取 启辰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-122.html 。。。\n",
      "--> 爬取 起亚 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-62.html 。。。\n",
      "--> 爬取 前途 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-235.html 。。。\n",
      "--> 爬取 乔治·巴顿 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-222.html 。。。\n",
      "--> 爬取 庆铃汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-312.html 。。。\n",
      "--> 爬取 全球鹰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-219.html 。。。\n",
      "--> 爬取 R汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-438.html 。。。\n",
      "--> 爬取 日产 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-63.html 。。。\n",
      "--> 爬取 荣威 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-19.html 。。。\n",
      "--> 爬取 容大智造 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-337.html 。。。\n",
      "--> 爬取 如虎 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-174.html 。。。\n",
      "--> 爬取 瑞驰新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-296.html 。。。\n",
      "--> 爬取 瑞麒 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-103.html 。。。\n",
      "--> 爬取 SERES赛力斯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-325.html 。。。\n",
      "--> 爬取 SHELBY 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-388.html 。。。\n",
      "--> 爬取 smart 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-45.html 。。。\n",
      "--> 爬取 SONGSAN MOTORS 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-436.html 。。。\n",
      "--> 爬取 SRM鑫源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-306.html 。。。\n",
      "--> 爬取 SWM斯威汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-269.html 。。。\n",
      "--> 爬取 萨博 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-64.html 。。。\n",
      "--> 爬取 赛麟 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-205.html 。。。\n",
      "--> 爬取 三菱 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-68.html 。。。\n",
      "--> 爬取 陕汽通家 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-149.html 。。。\n",
      "--> 爬取 上汽大通MAXUS 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-155.html 。。。\n",
      "--> 爬取 上喆 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-402.html 。。。\n",
      "--> 爬取 神州 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-426.html 。。。\n",
      "--> 爬取 世爵 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-66.html 。。。\n",
      "--> 爬取 双环 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-90.html 。。。\n",
      "--> 爬取 双龙 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-69.html 。。。\n",
      "--> 爬取 思皓 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-330.html 。。。\n",
      "--> 爬取 思铭 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-162.html 。。。\n",
      "--> 爬取 斯巴鲁 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-65.html 。。。\n",
      "--> 爬取 斯达泰克 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-238.html 。。。\n",
      "--> 爬取 斯柯达 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-67.html 。。。\n",
      "--> 爬取 速达 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-433.html 。。。\n",
      "--> 爬取 泰卡特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-202.html 。。。\n",
      "--> 爬取 特斯拉 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-133.html 。。。\n",
      "--> 爬取 腾势 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-161.html 。。。\n",
      "--> 爬取 天际汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-339.html 。。。\n",
      "--> 爬取 天美汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-400.html 。。。\n",
      "--> 爬取 WEY 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-283.html 。。。\n",
      "--> 爬取 瓦滋 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-408.html 。。。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--> 爬取 威麟 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-102.html 。。。\n",
      "--> 爬取 威马汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-291.html 。。。\n",
      "--> 爬取 威兹曼 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-99.html 。。。\n",
      "--> 爬取 潍柴汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-393.html 。。。\n",
      "--> 爬取 潍柴英致 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-192.html 。。。\n",
      "--> 爬取 蔚来 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-284.html 。。。\n",
      "--> 爬取 沃尔沃 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-70.html 。。。\n",
      "--> 爬取 五菱汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-114.html 。。。\n",
      "--> 爬取 五十铃 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-167.html 。。。\n",
      "--> 爬取 西雅特 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-98.html 。。。\n",
      "--> 爬取 现代 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-12.html 。。。\n",
      "--> 爬取 小鹏汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-275.html 。。。\n",
      "--> 爬取 晓奥汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-439.html 。。。\n",
      "--> 爬取 新宝骏 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-396.html 。。。\n",
      "--> 爬取 新凯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-185.html 。。。\n",
      "--> 爬取 新特汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-324.html 。。。\n",
      "--> 爬取 星途 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-350.html 。。。\n",
      "--> 爬取 雪佛兰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-71.html 。。。\n",
      "--> 爬取 雪铁龙 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-72.html 。。。\n",
      "--> 爬取 野马汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-111.html 。。。\n",
      "--> 爬取 野马新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-398.html 。。。\n",
      "--> 爬取 一汽 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-110.html 。。。\n",
      "--> 爬取 一汽凌河 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-399.html 。。。\n",
      "--> 爬取 依维柯 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-144.html 。。。\n",
      "--> 爬取 银隆新能源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-375.html 。。。\n",
      "--> 爬取 英菲尼迪 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-73.html 。。。\n",
      "--> 爬取 永源 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-93.html 。。。\n",
      "--> 爬取 宇通客车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-298.html 。。。\n",
      "--> 爬取 驭胜 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-263.html 。。。\n",
      "--> 爬取 御捷 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-232.html 。。。\n",
      "--> 爬取 裕路 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-307.html 。。。\n",
      "--> 爬取 远程汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-382.html 。。。\n",
      "--> 爬取 云度 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-286.html 。。。\n",
      "--> 爬取 云雀汽车 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-317.html 。。。\n",
      "--> 爬取 之诺 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-182.html 。。。\n",
      "--> 爬取 知豆 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-206.html 。。。\n",
      "--> 爬取 中华 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-22.html 。。。\n",
      "--> 爬取 中兴 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-74.html 。。。\n",
      "--> 爬取 众泰 品牌汽车的数据, url: https://car.autohome.com.cn/price/brand-94.html 。。。\n"
     ]
    }
   ],
   "source": [
    "all_brand_cars = []\n",
    "for brand in brand_urls:\n",
    "    brand_url = brand_urls[brand]\n",
    "    print('--> 爬取 {} 品牌汽车的数据, url: {} 。。。'.format(brand, brand_url))\n",
    "    brand_cars = fetch_brand_cars_info(brand, brand_url)\n",
    "    all_brand_cars.extend(brand_cars)\n",
    "    time.sleep(1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1258"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(all_brand_cars)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "共爬取 1258 个汽车信息\n"
     ]
    }
   ],
   "source": [
    "print('共爬取 {} 个汽车信息'.format(len(all_brand_cars)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "with open('all_car_info.txt', 'w', encoding='utf8')  as f:\n",
    "    f.writelines([json.dumps(l, ensure_ascii=False) + '\\n' for l in all_brand_cars])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    1258 all_car_info.txt\r\n"
     ]
    }
   ],
   "source": [
    "!wc -l all_car_info.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}